package edu.gxnu.cetcdemo.controller;

import edu.gxnu.cetcdemo.pojo.Room;
import edu.gxnu.cetcdemo.service.RoomService;
import edu.gxnu.cetcdemo.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class RoomController {
    @Autowired
    private RoomService roomService;


    @GetMapping("/room")
    @ApiOperation(value = "查询机房接口")
    public Result get(){
        return roomService.get();
    }
    @PostMapping("/room")
    @ApiOperation(value = "添加机房接口")
    public Result add(@RequestBody Room room){
        return roomService.add(room);
    }

    @DeleteMapping("/room/{id}")
    @ApiOperation(value = "删除机房接口")
    public Result delete(@PathVariable Integer id){
        return roomService.delete(id);
    }

    @PutMapping("/room")
    @ApiOperation(value = "修改机房接口")
    public Result put(@RequestBody Room room){
        return roomService.change(room);
    }


    @GetMapping("/room/name")
    public Result roomName(){ return roomService.getRoomName();}
}
